home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-15 | 3.2 KB | 142 lines | [TEXT/CWIE] |
- /*
-
- File: PreferencesDialogWindow.cp
- Project: Sample code for Sprocket Framework 1.1 (DR2), released 6/15/96
- Contains: A simple dialog window recipe
- To Do: Whatever your heart desires
-
- Sprocket Major Contributors:
- ----------------------------
- Dave Falkenburg, producer of Sprocket 1.0
- Bill Hayden, producer of Sprocket 1.1
- Steve Sisak, producer of the upcoming Sprocket 2.0
-
- Pete Alexander Steve Falkenburg Randy Thelen
- Eric Berdahl Nitin Ganatra Chris K. Thomas
- Marshall Clow Dave Hershey Leonard Rosenthal
- Tim Craycroft Dave Mark Dean Yu
- David denBoer Gary Powell
- Cameron Esfahani Jon Summers Apple Computer, Inc.
-
- Comments, Additions, or Corrections:
- ------------------------------------
- Bill Hayden, Nikol Software <nikol@codewell.com>
-
- */
-
-
- #include "Sprocket.h" // for gHasAppleGuide
- #include "PreferencesDialogWindow.h"
- #include "UGuide.h"
- #include "UDialog.h"
-
-
- #if GENERATINGPOWERPC
-
- #include "SpokenCommandHandler.h"
-
- extern TSpokenCommandHandler* SCH;
-
- #endif
-
-
-
- TPreferencesDialogWindow::TPreferencesDialogWindow() : TDialogWindow(kPreferencesDialogTemplateID)
- {
- // Because TDialogWindow::TDialogWindow has already created the dialog,
- // this is a great place to grab settings & setup the contents of the
- // dialog.
- //
- // Of course, if you do this you probably want to mark the DLOG
- // as not initially visible, then call ShowWindow just before returning.
- //
- // You should also setup UPPs for any user items in here, too.
-
- // Set up the default buttons
- // Isn’t it neat that these also work for modeless dialogs?
-
- this->CreateWindow(kModalWindow);
-
- if (fWindow)
- {
- SetDialogDefaultItem(this->GetDialogRef(), 1);
- SetDialogCancelItem(this->GetDialogRef(), 2);
- SetDialogTracksCursor(this->GetDialogRef(), true);
- }
-
- if (!gHasAppleGuide)
- {
- SetControlActive(this->GetDialogRef(), 3, false); // disable guide item
- }
-
- #if GENERATINGPOWERPC
- if (!SCH)
- {
- SetControlActive(this->GetDialogRef(), 4, false); // disable SR item
- }
- else
- {
- if (SCH->IsListening())
- ToggleCheckBox(this->GetDialogRef(), 4);
- }
- #else
- SetControlActive(this->GetDialogRef(), 4, false); // disable SR item
- #endif
- }
-
-
-
- void TPreferencesDialogWindow::ItemHit(short theItem)
- {
- OSErr err;
-
-
- switch (theItem)
- {
- case ok:
- #if GENERATINGPOWERPC
- if (SCH)
- {
- short state = GetControlSetting(this->GetDialogRef(), 4);
-
- if (state && !SCH->IsListening())
- SCH->StartListening();
- else if (!state && SCH->IsListening())
- SCH->StopListening();
-
- }
- #endif
- case cancel:
- this->Close();
- delete this;
- break;
-
- case 3: // our Guide item
- err = OpenGuideFile();
- if (err == kAGErrDatabaseNotAvailable)
- ErrorAlert(131, 1, false);
- else if (err)
- ErrorReporter(err, __FILE__, __LINE__);
- break;
-
- #if GENERATINGPOWERPC
- case 4: // Enable speech recognition
- ToggleCheckBox(this->GetDialogRef(), 4);
- break;
- #endif
-
- default:
- break;
- }
- }
-
-
-
- void TPreferencesDialogWindow::AdjustMenusBeforeMenuSelection(void)
- {
- gMenuBar->EnableCommand ( cCut, true );
- gMenuBar->EnableCommand ( cCopy, true );
- gMenuBar->EnableCommand ( cPaste, true );
- gMenuBar->EnableCommand ( cClear, true );
- gMenuBar->EnableCommand ( cSelectAll, true );
- }